<div class="ibox-content">
    <form class="form-horizontal" method="post" action="{:url('Package/addsys')}">
        <div class="form-group">
            <label class="col-sm-2 control-label">{:lang('打包')}{:lang('version')}</label>
            <div class="col-sm-4">
                <input name="version" class="form-control" type="text" placeholder="{:lang('输入')}{:lang('version')}"
                       value="{$version|default=''}"/>
                <span class="help-block m-b-none">{:lang('系统当前的')}{:lang('version')}{:lang('为')}：{$version|default='1.0.1'}</span>
            </div>
            <label class="col-sm-1 control-label">{:lang('是否安装包')}</label>
            <div class="col-sm-2">
                <div class="checkbox ">
                    <input type="checkbox" id="visible1" value="1" name="install">
                    <label for="visible1"> {:lang('yes')} </label>
                </div>
                <span class="help-block m-b-none"></span>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">{:lang('升级包文件')}</label>
            <div class="col-sm-10">
                <textarea name="upgrade_list" class="form-control" cols="80" rows="15">{$upgrade_list|default=''}</textarea>
                <span class="help-block m-b-none">{:lang('一行一个文件或者目录')}</span></div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">{:lang('安装包文件')}</label>
            <div class="col-sm-10">
                <textarea name="install_list" class="form-control" cols="80" rows="15">{$install_list|default=''}</textarea>
                <span class="help-block m-b-none">{:lang('一行一个文件或者目录')},{:lang('生成安装包会加载')}</span></div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-8">
                <button type="button" class="btn  btn-info ajax-save-post" target-form="form-horizontal"
                        data-loading-text="Loading...">
                    <span class="ladda-label"> {:lang('确定打包')} </span>
                </button>
            </div>
        </div>
    </form>
</div>

<div class="ibox-title">
    {:lang('打包信息')}
</div>

<div class="ibox-content">
    <div class="row">
        <div class="col-sm-12 package-log"></div>
    </div>
</div>
<script>
    var fakeloaderBox='';

    $(document).ready(function () {
        //删除选中产品
        $("body").on("click", ".ajax-save-post", function () {
            var target, query, form;
            var target_form = $(this).attr('target-form');
            form = $('.' + target_form);
            query = form.serialize();
            target = form.get(0).action;
            $.ajax({
                type: "POST",
                url: target,
                data: query,
                dataType: "json",
                beforeSend: function(){
                    $('.fakeloader').html('<div class="ibox-content">{:lang('正在打包中请务操作其它')}</div>');
                    fakeloaderBox=layer.open({
                        type: 1,
                        shade: [0.2, '#393D49'],
                        closeBtn:1,
                        title: false, //不显示标题
                        content: $('.fakeloader'), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
                        cancel: function(){
                            //layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', {time: 5000, icon:6});
                        }
                    });
                },
                success: function (result) {
                    //log(textStatus);
                    if (result.code == '1') {
                        layer.msg(result.msg, {icon: 1, time: 500, shade: [0.5, '#000', true]}, function () {
                            $('.package-log').html(result.data);
                            layer.close(fakeloaderBox);
                        });
                    } else {
                        layer.msg(result.msg, {icon: 5});
                    }
                },
                error:function (xhr) {
                    alert("错误提示： " + xhr.status + " " + xhr.statusText);
                }
            });//end ajax post
        });
    })
</script>